package cn.com.taiji.pos.service.impl;

import cn.com.taiji.pos.entity.ItemS;
import cn.com.taiji.pos.entity.TradeConsumptionDetail;
import cn.com.taiji.pos.mapper.TradeConsumptionDetailMapper;
import cn.com.taiji.pos.service.ITradeConsumptionDetailService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.dreamyoung.mprelation.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 消费细单 服务实现类
 * </p>
 *
 * @author
 * @since 2021-03-01
 */
@Service
public class TradeConsumptionDetailServiceImpl extends ServiceImpl<TradeConsumptionDetailMapper, TradeConsumptionDetail> implements ITradeConsumptionDetailService {

    @Resource
    private TradeConsumptionDetailMapper tradeConsumptionDetailMapper;

    @Override
    public List<TradeConsumptionDetail> findByMainId(String id) {
        QueryWrapper<TradeConsumptionDetail> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("MAIN_ID", id);
        return this.list(queryWrapper);
    }

    @Override
    public List<ItemS> getSalesOrder(LocalDate searchDate) {
        return tradeConsumptionDetailMapper.getSalesOrder(searchDate);
    }

    @Override
    public IPage<ItemS> getSalesOrderPage(IPage<ItemS> page, LocalDate searchDate) {
        return tradeConsumptionDetailMapper.getSalesOrderPage(page, searchDate);

    }

    @Override
    public Double getDaySalesTotalAmount(LocalDate searchDate) {
        return tradeConsumptionDetailMapper.getDaySalesTotalAmount(searchDate);
    }

    @Override
    public List<ItemS> getSalesOrderGroupByFood(LocalDate searchDate, int isCreateInventory) {
        return tradeConsumptionDetailMapper.getSalesOrderGroupByFood(searchDate, isCreateInventory);
    }
}
